using Microsoft.AspNetCore.Mvc;
using ZR.Admin.WebApi.Filters;
using ZR.Model.Dto.Business.ProductionControl;
using ZR.Model.Models.ProductionControl;
using ZR.Service.IService.ProductionControl;

//创建时间：2024-10-20
namespace ZR.Admin.WebApi.Controllers
{
    /// <summary>
    /// 点检内容维护表
    /// </summary>
    [Verify]
    [Route("device/devicecheckcontent")]
    [ApiExplorerSettings(GroupName = "business")]
    public class DeviceCheckContentController : BaseController
    {
        /// <summary>
        /// 点检内容维护表接口
        /// </summary>
        private readonly IDeviceCheckContentService _DeviceCheckContentService;

        public DeviceCheckContentController(IDeviceCheckContentService DeviceCheckContentService)
        {
            _DeviceCheckContentService = DeviceCheckContentService;
        }

        /// <summary>
        /// 查询点检内容维护表列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "device:devicecheckcontent:list")]
        public IActionResult QueryDeviceCheckContent([FromQuery] DeviceCheckContentQueryDto parm)
        {
            var response = _DeviceCheckContentService.GetList(parm);
            return SUCCESS(response);
        }

        /// <summary>
        /// 查询点检内容维护表详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "device:devicecheckcontent:query")]
        public IActionResult GetDeviceCheckContent(int Id)
        {
            var response = _DeviceCheckContentService.GetInfo(Id);

            var info = response.Adapt<DeviceCheckContentDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加点检内容维护表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "device:devicecheckcontent:add")]
        [Log(Title = "点检内容维护表", BusinessType = BusinessType.INSERT)]
        public IActionResult AddDeviceCheckContent([FromBody] DeviceCheckContentDto parm)
        {
            var modal = parm.Adapt<DeviceCheckContent>().ToCreate(HttpContext);

            var response = _DeviceCheckContentService.AddDeviceCheckContent(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新点检内容维护表
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "device:devicecheckcontent:edit")]
        [Log(Title = "点检内容维护表", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateDeviceCheckContent([FromBody] DeviceCheckContentDto parm)
        {
            var modal = parm.Adapt<DeviceCheckContent>().ToUpdate(HttpContext);
            var response = _DeviceCheckContentService.UpdateDeviceCheckContent(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除点检内容维护表
        /// </summary>
        /// <returns></returns>
        [HttpDelete("delete/{ids}")]
        [ActionPermissionFilter(Permission = "device:devicecheckcontent:delete")]
        [Log(Title = "点检内容维护表", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteDeviceCheckContent([FromRoute] string ids)
        {
            var idArr = Tools.SplitAndConvert<int>(ids);

            return ToResponse(_DeviceCheckContentService.Delete(idArr));
        }
    }
}